package com.unionx.unionxuf.service;

import java.sql.Connection;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.unionx.unionxuf.common.DynamicConnect;
import com.unionx.unionxuf.dao.SubjectDao;
import com.unionx.unionxuf.entity.Code;
import com.unionx.unionxuf.entity.ReceivepayManger;
import com.unionx.unionxuf.entity.SDTD;
import com.unionx.unionxuf.entity.Settlestyle;
import com.unionx.unionxuf.localdao.SettlestyleMapper;


@Service("SubjectBindService")
public class SubjectBindServiceImpl implements SubjectBindService  {
    
	
	@Autowired(required=true)
	private SubjectDao subjectDao;

	@Autowired
	private SettlestyleMapper sm;

	
	public Object getSubject(HttpServletRequest request) {
		// TODO Auto-generated method stub
		return subjectDao.getSubject(request);
	}


	public Code getSubjectInfo(HttpServletRequest request,String code) {
		// TODO Auto-generated method stub
		return subjectDao.getSubjectInfo(request,code);
	}

	
	public Object getSettle(HttpServletRequest request,Integer pageSize, Integer pageNum) {
		// TODO Auto-generated method stub
		return subjectDao.getSettle(request,pageSize, pageNum);
	}

	
	public Object getSettleinfo(HttpServletRequest request) {
		// TODO Auto-generated method stub
		return subjectDao.getSettleInfo(request);
	}


	public Object getSettlename(HttpServletRequest request,String scode) {
		// TODO Auto-generated method stub
		return subjectDao.getSettlename(request,scode);
	}


	public Object getsubinfo(HttpServletRequest request) {
		// TODO Auto-generated method stub
		return subjectDao.getsubinfo(request);
	}


	public Object getsubname(HttpServletRequest request,String subcode) {
		// TODO Auto-generated method stub
		return subjectDao.getsubname(request,subcode);
	}


	public Object getSettles(HttpServletRequest request) {
		// TODO Auto-generated method stub
		return subjectDao.getSettles(request);
	}

	@Override
	public Object getlocalSettles(String cropid) {

		Map<String,Object> map = new HashMap<String,Object>();
		List<Settlestyle> list =  new ArrayList<Settlestyle>();
		
	
		List<String> slist = sm.selectByCp(cropid);
		for(int i=0;i<slist.size();i++){
			Settlestyle s = new Settlestyle();
					s.setSettlement(slist.get(i));
				list.add(s);
		}
		map.put("data", list);
		return map;
	}
}
